package leetcode.图.floyed;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author ：zsy
 * @date ：Created 2021/8/7 22:04
 * @description：floyed算法
 */
public class FloyedTest {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] points = new int[n][2];
        for (int[] point : points) {
            point[0] = in.nextInt();
            point[1] = in.nextInt();
        }
        int m = in.nextInt();
        double[][] edges = new double[m][m];
        for (double[] edge : edges) {
            Arrays.fill(edge, Double.MAX_VALUE);
        }
        for (int i = 0; i < m; i++) {
            int row = in.nextInt();
            int col = in.nextInt();
            edges[row - 1][col - 1] = Math.sqrt(Math.abs(
                    Math.pow(points[col - 1][0] - points[row - 1][0], 2)
                            + Math.pow(points[col - 1][1] - points[row - 1][1], 2)));
        }
        int s = in.nextInt();
        int t = in.nextInt();
        //floyed算法
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < m; j++) {
                    if (edges[i][k] + edges[k][j] < edges[i][j]) {
                        edges[i][j] = edges[i][k] + edges[k][j];
                    }
                }
            }
        }

        System.out.println(String.format("%.2f", edges[s - 1][t - 1]));
    }
}
/*5
0 0
2 0
2 2
0 2
3 1
5
1 2
1 3
1 4
2 5
3 5
1 5*/
